package adapter;

import java.util.ArrayList;

import utils.AccounListViewItem;

import com.example.lastprojectbeautiplus.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AccountListViewAdapter extends ArrayAdapter<AccounListViewItem> {
	private ArrayList<AccounListViewItem> accountTaskList;
	private Activity activity;
	private int Resource;
	ImageView imgIcon;
	TextView tvTitle;
	View view;

	public AccountListViewAdapter(Activity activity, int Resource,
			ArrayList<AccounListViewItem> accountTaskList) {
		super(activity, Resource, accountTaskList);
		this.accountTaskList = accountTaskList;
		this.activity = activity;
		this.Resource = Resource;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return accountTaskList.size();
	}

	public AccounListViewItem getItem(int position) {
		return accountTaskList.get(position);
	}

	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = convertView;
		if (view == null) {
			view = inflater.inflate(Resource, null);

		} else
			view = (View) convertView;
		imgIcon = (ImageView) view.findViewById(R.id.imgAccountIcon);
		tvTitle = (TextView) view.findViewById(R.id.tvAccountTittle);
		imgIcon.setImageResource(accountTaskList.get(position).getImgPath());
		tvTitle.setText(accountTaskList.get(position).getTitle());
		return view;
	}
}